const fs = require('fs');
const { traditionalToSimplified } = require('node-opencc');

// 读取文件
const input = fs.readFileSync('mychars.txt', 'utf8');

let result = '';

for (const ch of input) {
  const converted = traditionalToSimplified(ch);
  // 如果转换后的字与原字相同，说明不是“可转为简体的繁体字”，保留
  if (converted === ch) {
    result += ch;
  }
}

// 写出新文件
fs.writeFileSync('targetmychars.txt', result, 'utf8');
console.log('✅ 处理完成，已生成 targetmychars.txt');
